﻿using FreeSql.DataAnnotations;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Web.Api.Server.Models
{
    public enum OrderStats
    {
        /// <summary>
        /// 等待处理
        /// </summary>
        Wait = 0,
        /// <summary>
        /// 店主确认
        /// </summary>
        Accept,
        /// <summary>
        /// 关闭
        /// </summary>
        Close
    }

    [Table(Name = "orders")]
    public class Order
    {
        [Column(Name = "id", IsIdentity = true)]
        public int Id { get; set; }

        [Column(Name = "order_stats", MapType = typeof(int))]
        public OrderStats OrderStats { get; set; }

        [Column(Name = "total_price")]
        public decimal TotalPrice { get; set; }

        [Column(Name = "address")]
        public JObject Address { get; set; }

        [Column(Name = "remark", StringLength = 255, IsNullable = true)]
        public string Remark { get; set; }

        [Column(Name = "shop_id")]
        public int ShopId { get; set; }

        [Column(Name = "user_id")]
        public int UserId { get; set; }

        [Column(Name = "created_at", IsNullable = true)]
        public DateTime? CreatedAt { get; set; } = DateTime.Now;

        [Column(Name = "updated_at", IsNullable = true)]
        public DateTime? UpdatedAt { get; set; } = DateTime.Now;
    }
}
